package top.itaso.app.ui.treelevel;

import androidx.lifecycle.ViewModelProvider;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import top.itaso.app.R;
import top.itaso.app.databinding.FragmentTreeListviewBinding;
import top.itaso.app.ui.treelevel.adapter.NodeTreeAdapter;

/**
 * @Description: 多级列表
 * @Author itsdf07
 * @E-Mail 923255742@qq.com
 * @Gitee https://gitee.com/itsdf07
 * @Date 2021/12/5
 */
public class TreeListFragment extends Fragment {

    private MultiLevelListViewModel mViewModel;
    private FragmentTreeListviewBinding binding;

    private RecyclerView mMultiLevelList;
    private NodeTreeAdapter mAdapter;


    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        binding = FragmentTreeListviewBinding.inflate(inflater, container, false);
        mViewModel = new ViewModelProvider(this).get(MultiLevelListViewModel.class);
        View rootView = binding.getRoot();
        mMultiLevelList = rootView.findViewById(R.id.multilevel_list);
        mMultiLevelList.setLayoutManager(new LinearLayoutManager(requireContext()));
//        mAdapter = new TreeListAdapter(mViewModel.parseOrgMembers(mViewModel.readOrgMemberFromExcel()), 0, R.mipmap.ic_up_arrow, R.mipmap.ic_down_arrow);
        mAdapter = new NodeTreeAdapter(mViewModel.parseCrownCases(), 0, R.mipmap.ic_more_up, R.mipmap.ic_more_down);
        mMultiLevelList.setAdapter(mAdapter);

        return rootView;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

    }

}